package ioc

import (
	"github.com/IBM/sarama"
	"jk-time/webook/interactive/dao"
	articleEvents "jk-time/webook/interactive/events"
	"jk-time/webook/pkg/migrator/events/fixer"
	"jk-time/webook/pkg/saramax"
)

func InitKafka() sarama.Client {
	cfg := sarama.NewConfig()
	cfg.Producer.Return.Successes = true
	cfg.Producer.Return.Errors = true
	cfg.Producer.RequiredAcks = sarama.WaitForAll

	client, err := sarama.NewClient([]string{"192.168.71.130:9092"}, cfg)
	if err != nil {
		panic(err)
	}
	return client
}
func InitSyncProducer(client sarama.Client) sarama.SyncProducer {
	res, err := sarama.NewSyncProducerFromClient(client)
	if err != nil {
		panic(err)
	}
	return res
}
func InitConsumer(comsumer1 *articleEvents.InteractiveKafkaComsumer, comsumer2 *fixer.Consumer[dao.Interactive]) []saramax.Comsumer {
	return []saramax.Comsumer{comsumer1, comsumer2}
}
